<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:include="public/page_css::page_css ('修改周转箱')"/>

<body>
<div class="layui-fluid larry-wrapper">
    <div class="layui-row layui-col-space30">
        <div class="layui-col-xs24">
            <section class="panel panel-padding">
                <form id="form1" class="layui-form layui-form-pane" action="">
                    <div class="step-content" id="simplewizardinwidget-steps">
                        <div class="step-pane active" id="simplewizardinwidgetstep1">
                            <div>&nbsp;</div>
                            <input type="hidden" name="id">
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label" data-title>箱型</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="xx" placeholder="箱型" autocomplete="off"
                                               lay-verify="required" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">箱重量</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="xzl" placeholder="箱重量" lay-verify="required|number"
                                               autocomplete="off" class="layui-input " readonly="readonly" />
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">宽</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="k" name="k" value="1" lay-verify="required|number"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">高</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="g" name="g" value="1" lay-verify="required|number"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">长</label>
                                    <div class="layui-input-inline">
                                        <input type="text" id="c" name="c" value="1" lay-verify="required|number"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">最大重量</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="zdzl" placeholder="最大重量" lay-verify="required|number"
                                               autocomplete="off" class="layui-input " readonly="readonly"/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--浮动容积上限-->
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">浮动容积上限</label>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <input type="text" id="fdrj" name="fdrj" value="0" lay-verify="required|number"
                                   autocomplete="off" class="layui-input "/>
                        </div>
                        <!--装载率-->
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">装载率(0.01-1)</label>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <input type="text" id="zzl" name="zzl" placeholder="装载率" lay-verify="required|number"
                                   autocomplete="off" class="layui-input "/>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" jq-filter="submit" lay-submit="" lay-filter="editBox">立即提交
                                </button>
                               <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                            </div>
                        </div>
                        <input type="hidden" th:value="${id}" id="kid">
                        <input type="hidden" name="zdtj">
                        <input type="hidden" name="kytj">
                    </div>

                </form>
            </section>
        </div>
    </div>
</div>
</body>
<div th:include="public/public_js::public_js"></div>

<script th:inline="javascript">
    $(function () {

    })


</script>
<script>
    layui.use(['myform', 'zzpUtils', 'form', 'jquery'], function () {
        var form = layui.form,
            zzpUtils = layui.zzpUtils,
            $ = layui.jquery;
        var ids = $("#kid").val();
        zzpUtils.action({
            url: "/wmsturnoverbox/getWmsTurnoverBox",
            data: JSON.stringify({id: ids}),
            success: function (data) {
                zzpUtils.loadJsonDataToForm(data);
            }, error: function (xhr, textStatus) {
                console.log(textStatus);
                console.log(xhr)
            }
        });

        form.on("submit(editBox)", function (data) {
            var zzl = $("#zzl").val();//装载率
            var c = $("#c").val();//长
            var k = $("#k").val();//宽
            var g = $("#g").val();//高
            var fdrj = $("#fdrj").val();//浮动容积
            var ztj = c * k * g;
            var num = ztj * zzl;
            var num1 = ztj - num;
            zzpUtils.confirm("是否确定修改", function (index) {
                if (zzl < 0.01 || zzl > 1) {
                    layer.msg("装载率 介于0.01和1之间！");
                } else if (fdrj > num1) {
                    layer.msg("浮动容积上限 不能大于 可用容积:" + num1);
                } else {
                    zzpUtils.action({
                        url: "/wmsturnoverbox/edit",
                        data: JSON.stringify(data.field),
                        success: function (data) {
                            setTimeout(function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                                if(data.type=='success'){
                                    top.layer.msg(data.title);
                                }else{
                                    top.layer.msg(data.message);
                                }
                            }, 500);
                        }, error: function (xhr, textStatus) {
                            console.log(textStatus);
                            console.log(xhr)
                        }
                    })
                }
            })
            return false;

        });
    });
</script>
</html>